import request from './request'

export interface DatabaseConfig {
  id?: number
  index?: number
  name?: string
  databaseName: string
  ip: string
  port: number
  username: string
  password: string
}

/**
 * 测试数据库连接
 */
export const testDatabaseConnection = (data: DatabaseConfig) => {
  return request.post('/api/database/test-connection', data)
}

/**
 * 获取数据库列表
 */
export const getDatabaseList = () => {
  return request.get('/api/database/list')
}

/**
 * 添加数据库
 */
export const addDatabase = (data: DatabaseConfig) => {
  return request.post('/api/database/add', data)
}

/**
 * 更新数据库
 */
export const updateDatabase = (id: number, data: DatabaseConfig) => {
  return request.put(`/api/database/update/${id}`, data)
}

/**
 * 删除数据库
 */
export const deleteDatabase = (id: number) => {
  return request.delete(`/api/database/delete/${id}`)
}




